#include <gxgfunc.h>

#define STR_LEN 8
int getRandStr(char* mystr) {
    char str[STR_LEN + 1] = {0};
    int i, flag;
    srand(time(NULL));
    for (i = 0; i < STR_LEN; i++) {
        flag = rand() % 3;
        switch (flag) {
            case 0:
                str[i] = rand() % 26 + 'a';
                break;
            case 1:
                str[i] = rand() % 26 + 'A';
                break;
            case 2:
                str[i] = rand() % 10 + '0';
                break;
        }
    }
    strcpy(mystr, str);
}

int main() {
    char username[1024] = {0};
    char passwd[20] = {0};
    char cryptpasswd[20] = {0};
    char salt[20] = {0};

    scanf("%s", username);
    scanf("%s", passwd);

    getRandStr(salt);
    puts(salt);

    strcpy(cryptpasswd, crypt(passwd, salt));
    puts(cryptpasswd);
}